home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / think / AmigaGnuChess.lha / chess / src.lha / src / amiga / amidsp.c next >
C/C++ Source or Header  |  1992-09-06  |  20KB  |  1,010 lines

  1. /*
  2.  * amidsp.c - Amiga interface for GNUCHESS, based on
  3.  * nuxdsp.c - (new)  ALPHA interface for CHESS
  4.  *
  5.  * Copyright (c) 1988,1989,1990 John Stanback
  6.  * Copyright (c) 1992 Free Software Foundation
  7.  * Copyright (c) 1992 Martin W. Scott
  8.  *
  9.  * This file is part of GNU CHESS.
  10.  *
  11.  * GNU Chess is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2, or (at your option)
  14.  * any later version.
  15.  *
  16.  * GNU Chess is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with GNU Chess; see the file COPYING.  If not, write to
  23.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25. #include <ctype.h>
  26. #include <signal.h>
  27. #include <sys/types.h>
  28. #include <stdarg.h>
  29.  
  30. #define BOARD_FOREGROUND    1
  31. #define TEXT_FOREGROUND        6
  32. #define INPUT_FOREGROUND    7
  33.  
  34. #if defined(__STDC__)
  35. /* <stdlib.h> */
  36.      extern void *malloc (size_t);
  37.      extern void exit (int);
  38.  
  39. /* <string.h> */
  40.      extern char *strcat (char *, const char *);
  41.      extern int strcmp (const char *, const char *);
  42.      extern char *strcpy (char *, const char *);
  43.  
  44. /* <time.h> */
  45.      extern long int time (long int *);
  46. #endif
  47.  
  48. #include "gnuchess.h"
  49. #include "amiterm.h"
  50. #include "draw.h"
  51.  
  52. extern short int sscore[];
  53. extern short int pscore[2];
  54.  
  55. #define TAB (45)
  56. /* coordinates within a square for the following are ([1,5],[1,3]) */
  57. #define SQW (5)
  58. #define SQH (3)
  59. #define VIR_C(s)  ((flag.reverse) ? 7-column(s) : column(s))
  60. #define VIR_R(s)  ((flag.reverse) ? 7-row(s) : row(s))
  61. #define VSQ_X(x)  ((flag.reverse) ? SQW + 1 - (x) : (x))
  62. #define VSQ_Y(y)  ((flag.reverse) ? SQH + 1 - (y) : (y))
  63. #define Vblack(s) (!((VIR_C(s) + VIR_R(s)) % 2))
  64. /* Squares swapped */
  65. #define Vcoord(s,x,y) \
  66.     ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(y))
  67. /* Squares and internal locations swapped */
  68. #define VcoordI(s,x,y) \
  69.     ((SQW)*(VIR_C(s)))+(VSQ_X(x)),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
  70. /* Squares and internal rows swapped */
  71. #define VcoordR(s,x,y) \
  72.     ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
  73. char Analysis[128] = "";
  74. unsigned short int MV[MAXDEPTH];
  75. int MSCORE;
  76. char *DRAW;
  77. extern char mvstr[4][6];
  78. extern short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
  79. short PositionFlag = 0;
  80. void TerminateSearch (int), Die (int);
  81.  
  82. #define OReverse standout
  83. #define ONormal standend
  84.  
  85. cursoron()
  86. {
  87.     leaveok(NULL, 0);        /* cursor on... */
  88.     attron(INPUT_FOREGROUND);    
  89.     printw("");
  90.     refresh();
  91. }
  92.  
  93. cursoroff()
  94. {
  95.     attron(TEXT_FOREGROUND);    
  96.     leaveok(NULL, 1);        /* ...cursor off */
  97. }
  98.  
  99. /* max. of 3 parameters... */
  100. ami_scanw(char *fmt, void *a1, void *a2, void *a3)/* aesthetic curses... */
  101. {
  102.     int rv;
  103.     cursoron();
  104. #ifdef I_WISH
  105.     rv = vscanw(fmt, (long *)ap);
  106. #else
  107.     rv = scanw(fmt, a1, a2, a3);
  108. #endif
  109.     cursoroff();
  110.     return rv;
  111. }
  112.  
  113. void
  114. Initialize (void)
  115. {
  116.   signal (SIGINT, Die);
  117. #ifndef AMIGA
  118.   signal (SIGQUIT, Die);
  119. #endif
  120.   initscr ();
  121.   attron(TEXT_FOREGROUND);
  122.   leaveok(NULL, 1);        /* ...cursor off */
  123.   gotoXY(22,12);
  124.   printw("Welcome to GNU CHESS. Initialising...");
  125.   refresh();
  126.   crmode ();
  127. }
  128.  
  129. void
  130. ExitChess (void)
  131. {
  132. #ifdef ALWAYSLIST
  133.   ListGame ();
  134. #endif
  135.   refresh();
  136.   nocrmode ();
  137.   endwin ();
  138.   exit (0);
  139. }
  140.  
  141. void
  142. Die (int Sig)
  143. {
  144.   char s[80];
  145.  
  146.   signal (SIGINT, SIG_IGN);
  147. #ifndef AMIGA
  148.   signal (SIGQUIT, SIG_IGN);
  149. #endif
  150.   ShowMessage (CP[31]);        /*Abort?*/
  151.   scanz ("%s", s);
  152.   if (stricmp (s, CP[210]) == 0)    /*yes*/
  153.     ExitChess ();
  154.   signal (SIGINT, Die);
  155. #ifndef AMIGA
  156.   signal (SIGQUIT, Die);
  157. #endif
  158. }
  159.  
  160. void
  161. TerminateSearch (int Sig)
  162. {
  163.   signal (SIGINT, SIG_IGN);
  164. #ifndef AMIGA
  165.   signal (SIGQUIT, SIG_IGN);
  166. #endif
  167.   if (!flag.timeout)
  168.     flag.musttimeout = true;
  169.   flag.bothsides = false;
  170.   signal (SIGINT, Die);
  171. #ifndef AMIGA
  172.   signal (SIGQUIT, Die);
  173. #endif
  174. }
  175.  
  176. void
  177. ShowLine (unsigned short int *bstline)
  178. {
  179. }
  180.  
  181. void
  182. help (void)
  183. {
  184.   ClrScreen ();
  185.   /*printz ("CHESS command summary\n");*/
  186. #ifdef NON_GFX
  187.   printz (CP[40]);
  188.   printz ("----------------------------------------------------------------\n");
  189. #else
  190.   attron(HILITE_PEN);
  191.   printz (CP[40]);
  192.   attron(TEXT_PEN);
  193. #endif
  194.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  195.   printz (CP[158]);
  196.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  197.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  198.   /*printz ("a7a8q     promote pawn to queen\n");*/
  199.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  200.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  201.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  202.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  203.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  204.   /*printz ("bd        redraw board            reverse   board display\n");*/
  205.   printz (CP[130]);
  206.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount, BOOKSIZE);*/
  207.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  208.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  209.   printz (CP[200]);
  210.   /*printz ("edit      edit board              force     enter game moves\n");*/
  211.   printz (CP[153]);
  212.   /*printz ("switch    sides with computer     both      computer match\n");*/
  213.   printz (CP[194]);
  214.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  215.   printz (CP[202]);
  216.   /*printz ("depth     set search depth        clock     set time control\n");*/
  217.   printz (CP[149]);
  218.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" : "on");*/
  219.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  220.   /*printz ("save      game to file            get       game from file\n");*/
  221.   printz (CP[188]);
  222.   /*printz ("random    randomize play          new       start new game\n");*/
  223.   printz (CP[181]);
  224.   /*printz ("coords    show coords            rv        reverse video\n");*/
  225.   printz (CP[144]);
  226. #ifdef NON_GFX
  227.   printz (CP[192]);
  228. #define INCREMENT 0
  229. #else
  230. #define INCREMENT -1
  231. #endif
  232.   gotoXY (10, 20+INCREMENT);
  233.   printz (CP[47], ColorStr[computer]);
  234.   gotoXY (10, 21+INCREMENT);
  235.   printz (CP[97], ColorStr[opponent]);
  236.   gotoXY (10, 22+INCREMENT);
  237.   printz (CP[79], MaxResponseTime/100);
  238. #ifdef NON_GFX
  239.   gotoXY (10, 23+INCREMENT);
  240.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  241. #endif
  242.   gotoXY (40, 20+INCREMENT);
  243.   printz (CP[52], MaxSearchDepth);
  244.   gotoXY (40, 21+INCREMENT);
  245.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  246.   gotoXY (40, 22+INCREMENT);
  247.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  248. #ifdef NON_GFX
  249.   gotoXY (40, 23+INCREMENT);
  250.   printz (CP[73]);
  251.   gotoXY (10, 24+INCREMENT);
  252.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  253.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  254. #else
  255.   gotoXY (10, 23+INCREMENT);
  256.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  257.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  258. #endif
  259.   refresh ();
  260.   getch ();
  261.   ClrScreen ();
  262.   UpdateDisplay (0, 0, 1, 0);
  263. }
  264.  
  265. void
  266. EditBoard (void)
  267.  
  268. /*
  269.  * Set up a board position. Pieces are entered by typing the piece followed
  270.  * by the location. For example, Nf3 will place a knight on square f3.
  271.  */
  272.  
  273. {
  274.   short a, r, c, sq, i;
  275.   char s[80];
  276.  
  277.   flag.regularstart = false;
  278.   Book = false;
  279.   ClrScreen ();
  280.   UpdateDisplay (0, 0, 1, 0);
  281.   gotoXY (TAB, 3);
  282.   printz (CP[29]);
  283.   gotoXY (TAB, 4);
  284.   printz (CP[28]);
  285.   gotoXY (TAB, 5);
  286.   printz (CP[136]);
  287.   gotoXY (TAB, 7);
  288.   printz (CP[64]);
  289.   a = white;
  290.   do
  291.     {
  292.       gotoXY (TAB, 6);
  293.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  294.       gotoXY (TAB + 24, 7);
  295.       ClrEoln ();
  296.       scanz ("%s", s);
  297.       if (s[0] == CP[28][0])    /*#*/
  298.     {
  299.           attron(BOARD_FOREGROUND);
  300.       for (sq = 0; sq < 64; sq++)
  301.         {
  302.           board[sq] = no_piece;
  303.           color[sq] = neutral;
  304.           DrawPiece (sq);
  305.         }
  306.           attron(TEXT_FOREGROUND);
  307.     }
  308.       if (s[0] == CP[136][0])    /*c*/
  309.     a = otherside[a];
  310.       c = s[1] - 'a';
  311.       r = s[2] - '1';
  312.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  313.     {
  314.       sq = locn (r, c);
  315.       for (i = king; i > no_piece; i--)
  316.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  317.           break;
  318.       board[sq] = i;
  319.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  320.           attron(BOARD_FOREGROUND);
  321.       DrawPiece (sq);
  322.           attron(TEXT_FOREGROUND);
  323.     }
  324.   } while (s[0] != CP[29][0]);
  325.  
  326.   for (sq = 0; sq < 64; sq++)
  327.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  328.   GameCnt = 0;
  329.   Game50 = 1;
  330.   ZeroRPT ();
  331.   Sdepth = 0;
  332.   InitializeStats ();
  333.   ClrScreen ();
  334.   UpdateDisplay (0, 0, 1, 0);
  335. }
  336.  
  337. void
  338. ShowPlayers (void)
  339. {
  340.   gotoXY (TAB, ((flag.reverse) ? 21 : 2));
  341.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  342.   ClrEoln ();
  343.   gotoXY (TAB, ((flag.reverse) ? 2 : 21));
  344.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  345.   ClrEoln ();
  346. }
  347.  
  348. void
  349. ShowDepth (char ch)
  350. {
  351.   gotoXY (TAB, 4);
  352.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  353.   ClrEoln ();
  354. }
  355.  
  356. void
  357. ShowScore (short score)
  358. {
  359.   gotoXY (TAB, 5);
  360.   printz (CP[104], score);
  361.   ClrEoln ();
  362. }
  363.  
  364. void
  365. ShowMessage (char *s)
  366. {
  367.   gotoXY (TAB, 17);
  368.   printz ("%s", s);
  369.   ClrEoln ();
  370. }
  371.  
  372. void
  373. WarnMessage (char *s)
  374. {
  375.   attron(HILITE_PEN);
  376.   ShowMessage(s);
  377.   attron(TEXT_FOREGROUND);
  378. }
  379.  
  380. void
  381. ClearMessage (void)
  382. {
  383.   gotoXY (TAB, 17);
  384.   ClrEoln ();
  385. }
  386.  
  387. void
  388. ShowCurrentMove (short int pnt, short int f, short int t)
  389. {
  390.   algbr (f, t, false);
  391.   gotoXY (TAB, 7);
  392.   printz ("(%2d) %4s", pnt, mvstr[0]);
  393. }
  394.  
  395. void
  396. ShowHeader (void)
  397. {
  398. #ifdef NON_GFX
  399.   gotoXY (TAB, 10);
  400.   printz (CP[68]);
  401. #endif
  402. }
  403.  
  404. void
  405. ShowSidetoMove (void)
  406. {
  407.   gotoXY (TAB, 13);
  408.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  409.   ClrEoln ();
  410. }
  411.  
  412. void
  413. ShowPrompt (void)
  414. {
  415.   gotoXY (TAB, 16);
  416.   printz (CP[121]);        /*Your movwe is?*/
  417.   ClrEoln ();
  418. }
  419.  
  420. void
  421. ShowNodeCnt (long int NodeCnt)
  422. {
  423.   gotoXY (TAB, 18);
  424.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  425.   ClrEoln ();
  426.   refresh();
  427. }
  428.  
  429. void
  430. ShowResults (short int score, unsigned short int *bstline, char ch)
  431. {
  432.   unsigned char d, ply;
  433.  
  434.   if (flag.post)
  435.     {
  436.       ShowDepth (ch);
  437.       ShowScore (score);
  438.       d = 7;
  439.       for (ply = 1; bstline[ply] > 0; ply++)
  440.     {
  441.       if (ply % 4 == 1)
  442.         {
  443.           gotoXY (TAB, ++d);
  444.           ClrEoln ();
  445.         }
  446.       algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
  447.       printz ("%5s ", mvstr[0]);
  448.     }
  449.       ClrEoln ();
  450.       while (d < 12)
  451.     {
  452.       gotoXY (TAB, ++d);
  453.       ClrEoln ();
  454.     }
  455.     }
  456. }
  457.  
  458. void
  459. SearchStartStuff (short int side)
  460. {
  461.   short i;
  462.  
  463.   signal (SIGINT, TerminateSearch);
  464. #ifndef AMIGA
  465.   signal (SIGQUIT, TerminateSearch);
  466. #endif
  467.   for (i = 4; i < 13; i++)
  468.     {
  469.       gotoXY (TAB, i);
  470.       ClrEoln ();
  471.     }
  472. }
  473.  
  474. void
  475. OutputMove (void)
  476. {
  477.   UpdateDisplay (rootnode.f, rootnode.t, 0, (short) rootnode.flags);
  478.   gotoXY (TAB, 15);
  479.   if(flag.illegal) {printz (CP[225]); return;}
  480.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  481.   if (flag.beep)
  482.   beep();
  483.   ClrEoln ();
  484.  
  485.   gotoXY (TAB, 22);
  486.   if (rootnode.flags & draw)
  487.     printz (CP[56], DRAW);
  488.   else if (rootnode.score == -9999)
  489.     printz (CP[95]);
  490.   else if (rootnode.score == 9998)
  491.     printz (CP[44]);
  492.  
  493.   ClrEoln ();
  494.  
  495.   if (flag.post)
  496.     {
  497.       register short h, l, t;
  498.  
  499.       h = TREE;
  500.       l = 0;
  501.       t = TREE >> 1;
  502.       while (l != t)
  503.     {
  504.       if (Tree[t].f || Tree[t].t)
  505.         l = t;
  506.       else
  507.         h = t;
  508.       t = (l + h) >> 1;
  509.     }
  510.  
  511.  
  512.       ShowNodeCnt (NodeCnt);
  513.       gotoXY (TAB, 19);
  514.  
  515.       printz (CP[81], t);    /*Max Tree= %d*/
  516.       ClrEoln ();
  517.     }
  518. }
  519.  
  520. static void
  521. DoClockUpdate (short who)
  522. {
  523.   short m, s;
  524.  
  525.   m = (short) (et / 6000);
  526.   s = (short) (et - 6000 * (long) m) / 100;
  527.   if (TCflag)
  528.     {
  529.       m = (short) ((TimeControl.clock[who] - et) / 6000);
  530.       s = (short) ((TimeControl.clock[who] - et - 6000 * (long) m) / 100);
  531.     }
  532.   if (m < 0)
  533.     m = 0;
  534.   if (s < 0)
  535.     s = 0;
  536.   if (who == white)
  537.     gotoXY (60, (flag.reverse) ? 2 : 21);
  538.   else
  539.     gotoXY (60, (flag.reverse) ? 21 : 2);
  540.   printz ("%d:%02d   ", m, s);
  541.   if (flag.post)
  542.     ShowNodeCnt (NodeCnt);
  543.   refresh ();
  544. }
  545.  
  546. void
  547. UpdateClocks (void)
  548. {
  549.     DoClockUpdate(player);
  550. }
  551.  
  552. void
  553. gotoXY (short int x, short int y)
  554. {
  555.   move (y - 1, x - 1);
  556. }
  557.  
  558. void
  559. ClrScreen (void)
  560. {
  561.   clear ();
  562.   refresh ();
  563. }
  564.  
  565. void
  566. ClrEoln (void)
  567. {
  568.   clrtoeol ();
  569.   refresh ();
  570. }
  571.  
  572. #ifndef NON_GFX
  573. void
  574. FlashDrawPiece(short int sq)
  575. {
  576. #ifndef NON_GFX
  577.     /* fancy bitmapped stuff */
  578.     AmiFlashSquare(VIR_R(sq), VIR_C(sq));
  579. #endif
  580.     DrawPiece(sq);
  581. }
  582. #endif /* NON_GFX */
  583.  
  584. void
  585. DrawPiece (short int sq)
  586. {
  587. #ifndef NON_GFX
  588.     /* fancy bitmapped stuff */
  589.     UWORD pc;
  590.     pc = (color[sq] == white ? WHITE : BLACK);
  591.     AmiDrawSquare(VIR_R(sq), VIR_C(sq));
  592.     if (color[sq] != neutral)
  593.         AmiDrawPiece(board[sq]-1, pc, VIR_R(sq), VIR_C(sq));
  594. #else
  595.   gotoXY (VcoordR (sq, 2, 2));
  596.     switch (color[sq])
  597.     {
  598.      case black:
  599.       if (flag.rv)
  600.     OReverse ();
  601.       printz ((flag.stars ? "*%c*" : " %c "), pxx[board[sq]]);
  602.       ONormal ();
  603.       break;
  604.     case neutral:
  605.       if (flag.shade)
  606.     printz (Vblack (sq) ? "///" : "   ");
  607.       else
  608.     {
  609. #ifdef AMIGA
  610.       if (!Vblack (sq))    /* white in bottom-rh corner! */
  611. #else
  612.       if (Vblack (sq))
  613. #endif
  614.         OReverse ();
  615.       printz ("   ");
  616.       ONormal ();
  617.     }
  618.       break;
  619.     case white:
  620.       printz (" %c ", pxx[board[sq]]);
  621.       break;
  622.     default:
  623.       ShowMessage (CP[55]);    /*Draw piece color[sq] err*/
  624.       break;
  625.     }
  626. #endif /* NON_GFX */
  627. }
  628.  
  629. void
  630. DrawSquare (short int sq)
  631. {
  632. #ifndef NON_GFX
  633.     /* fancy bitmapped stuff */    
  634.     AmiDrawSquare(VIR_R(sq), VIR_C(sq));
  635. #else
  636.       if (!Vblack (sq))
  637.     OReverse ();
  638.       gotoXY (Vcoord (sq, 1, 1));
  639.       printz ("     ");
  640.       gotoXY (Vcoord (sq, 1, 2));
  641.       printz ("     ");
  642.       gotoXY (Vcoord (sq, 1, 3));
  643.       printz ("     ");
  644.       ONormal ();
  645. #endif /* NON_GFX */
  646. }
  647.  
  648. void
  649. DrawCoords (void)
  650. {
  651. #ifndef NON_GFX
  652.     /* snazzy graphics! */
  653.     AmiDrawCoords(0, flag.reverse);        /* draw them */
  654. #else
  655.   short z;
  656.   for (z = 0; z <= 7; z++)
  657.     {
  658.       short sq;
  659.  
  660.       sq = z << 3;
  661.       gotoXY (VcoordI (sq, 1, 1));
  662.       if ((!Vblack (sq) || flag.shade) && flag.rv)
  663.     OReverse ();
  664.       printz ("%d", 1 + z);
  665.       ONormal ();
  666.     }
  667.  
  668.   for (z = 0; z <= 7; z++)
  669.     {
  670.       short sq;
  671.  
  672.       sq = z;
  673.       gotoXY (VcoordI (sq, SQW, SQH));
  674.       if ((!Vblack (sq) || flag.shade) && flag.rv)
  675.     OReverse ();
  676.       printz ("%c", cxx[z]);
  677.       ONormal ();
  678.     }
  679.  
  680.   for (z = 1; z <= (8 * SQH); z++)
  681.     {
  682.       gotoXY ((8 * SQW) + 1, z);
  683.       printz ("|");
  684.     }
  685. #endif /* NON_GFX */
  686. }
  687.  
  688. void
  689. ShowPostnValue (short int sq)
  690.  
  691. /*
  692.  * must have called ExaminePosition() first
  693.  */
  694.  
  695. {
  696. #ifdef REALLY_DEBUG
  697.   short score;
  698.  
  699.   gotoXY (VcoordR (sq, 2, 1));
  700.   score = ScorePosition (color[sq]);
  701.   if (!Vblack (sq) && !flag.shade)
  702.     OReverse ();
  703.  
  704.   if (color[sq] != neutral)
  705.     printz ("%3d", svalue[sq]);
  706.   else
  707.     printz (flag.shade && Vblack (sq) ? "///" : "   ");
  708.   ONormal ();
  709. #endif
  710. }
  711.  
  712. void
  713. ShowPostnValues (void)
  714. {
  715. #ifdef REALLY_DEBUG
  716.   short sq, score;
  717.  
  718.   ExaminePosition ();
  719.   for (sq = 0; sq < 64; sq++)
  720.     ShowPostnValue (sq);
  721.   score = ScorePosition (opponent);
  722.   gotoXY (TAB, 5);
  723.  printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  724.   ClrEoln ();
  725. #endif
  726. }
  727.  
  728. void
  729. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  730. {
  731.   short sq;
  732.  
  733.   if (redraw)
  734.     {
  735.       attron(TEXT_FOREGROUND);
  736.       ShowHeader ();
  737.       ShowPlayers ();
  738.       DoClockUpdate (white);
  739.       DoClockUpdate (black);
  740. #ifndef NON_GFX
  741.     /* fancy bitmap graphics */
  742.     AmiDrawGrid();
  743.         for (sq = 0; sq < 64; sq++)
  744.     {
  745.       DrawPiece (sq);
  746.     }
  747.       if (flag.coords)
  748.     AmiDrawCoords (0, flag.reverse);
  749.       else
  750.     AmiDrawCoords (1, flag.reverse);
  751. #else    
  752.       attron(BOARD_FOREGROUND);
  753.       for (sq = 0; sq < 64; sq++)
  754.     {
  755.       DrawSquare (sq);
  756.       DrawPiece (sq);
  757.     }
  758.       if (flag.coords)
  759.     DrawCoords ();
  760. #endif /* NON_GFX */
  761.     }
  762.   else
  763.     {
  764.       attron(BOARD_FOREGROUND);
  765.       FlashDrawPiece (f);
  766.       FlashDrawPiece (t);
  767.  
  768.       DrawPiece (f);
  769.       DrawPiece (t);
  770.  
  771.       if (isspec & cstlmask)
  772.     if (t > f)
  773.       {
  774.         FlashDrawPiece (f + 3);
  775.         FlashDrawPiece (t - 1);
  776.       }
  777.     else
  778.       {
  779.         FlashDrawPiece (f - 4);
  780.         FlashDrawPiece (t + 1);
  781.       }
  782.       else if (isspec & epmask)
  783.     {
  784.       FlashDrawPiece (t - 8);
  785.       DrawPiece (t + 8);
  786.     }
  787.     }
  788.   if (PositionFlag)
  789.     ShowPostnValues ();
  790.   attron(TEXT_FOREGROUND);
  791.   refresh ();
  792. }
  793.  
  794. extern char *InPtr;
  795. void
  796. skip ()
  797. {
  798.   while (*InPtr != ' ')
  799.     InPtr++;
  800.   while (*InPtr == ' ')
  801.     InPtr++;
  802. }
  803. void
  804. skipb ()
  805. {
  806.   while (*InPtr == ' ')
  807.     InPtr++;
  808. }
  809.  
  810. void
  811. ChangeAlphaWindow (void)
  812. {
  813.   ShowMessage (CP[114]);
  814.   scanz ("%hd", &WAwindow);
  815.   ShowMessage (CP[34]);
  816.   scanz ("%hd", &BAwindow);
  817. }
  818.  
  819. void
  820. ChangeBetaWindow (void)
  821. {
  822.   ShowMessage (CP[115]);
  823.   scanz ("%hd", &WBwindow);
  824.   ShowMessage (CP[35]);
  825.   scanz ("%hd", &BBwindow);
  826. }
  827.  
  828. void
  829. GiveHint (void)
  830. {
  831.   char s[40];
  832.   if (hint)
  833.     {
  834.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  835.       strcpy (s, CP[198]);    /*try*/
  836.       strcat (s, mvstr[0]);
  837.       ShowMessage (s);
  838.     }
  839.   else
  840.     ShowMessage (CP[223]);
  841. }
  842.  
  843. void
  844. ChangeHashDepth (void)
  845. {
  846.   ShowMessage (CP[163]);
  847.   scanz ("%hd", &HashDepth);
  848.   ShowMessage (CP[82]);
  849.   scanz ("%hd", &HashMoveLimit);
  850. }
  851.  
  852. void
  853. ChangeSearchDepth (void)
  854. {
  855.   ShowMessage (CP[150]);
  856.   scanz ("%hd", &MaxSearchDepth);
  857.   TCflag = !(MaxSearchDepth > 0);
  858. }
  859.  
  860. void
  861. SetContempt (void)
  862. {
  863.   ShowMessage (CP[142]);
  864.   scanz ("%hd", &contempt);
  865. }
  866.  
  867.  
  868. void
  869. SetAnalysis (void)
  870. {
  871.   ShowMessage (CP[159]);
  872.   scanz ("%s", Analysis);
  873. }
  874.  
  875. void
  876. ChangeXwindow (void)
  877. {
  878.   ShowMessage (CP[208]);
  879.   scanz ("%hd", &xwndw);
  880. }
  881.  
  882. void
  883. SelectLevel (void)
  884. {
  885.   int i;
  886.   int item;
  887.  
  888.   ClrScreen ();
  889.   gotoXY (37, 2);
  890.   printz (CP[41]);
  891.   for (i = 0; i < 10; i++)
  892.   {
  893.       gotoXY (25, 4+i);
  894.     printz (CP[18+i]);
  895.   }
  896.  
  897.   OperatorTime = 0;
  898.   TCmoves = 60;
  899.   TCminutes = 5;
  900.   TCseconds = 0;
  901.   gotoXY (25, 17);
  902.   printz (CP[62]);
  903.   refresh ();
  904.   scanz ("%d", &item);
  905.   switch (item)
  906.     {
  907.     case 1:
  908.       TCmoves = 60; 
  909.       TCminutes = 5;
  910.       break;
  911.     case 2:
  912.       TCmoves = 60;
  913.       TCminutes = 15;
  914.       break;
  915.     case 3:
  916.       TCmoves = 60;
  917.       TCminutes = 30;
  918.       break;
  919.     case 4:
  920.       TCmoves = 40;
  921.       TCminutes = 30;
  922.       break;
  923.     case 5:
  924.       TCmoves = 40;
  925.       TCminutes = 60;
  926.       break;
  927.     case 6:
  928.       TCmoves = 40;
  929.       TCminutes = 120;
  930.       break;
  931.     case 7:
  932.       TCmoves = 40;
  933.       TCminutes = 240;
  934.       break;
  935.     case 8:
  936.       TCmoves = 1;
  937.       TCminutes = 15;
  938.       break;
  939.     case 9:
  940.       TCmoves = 1;
  941.       TCminutes = 60;
  942.       break;
  943.     case 10:
  944.       TCmoves = 1;
  945.       TCminutes = 600;
  946.       break;
  947.     }
  948.   TCflag = (TCmoves > 0);
  949.   ResetTimeControl ();
  950.   ClrScreen ();
  951.   UpdateDisplay (0, 0, 1, 0);
  952. }
  953.  
  954. void
  955. DoDebug (void)
  956. {
  957. #ifdef REALLY_DEBUG
  958.   short c, p, sq, tp, tc, tsq, score;
  959.   char s[40];
  960.  
  961.   ExaminePosition ();
  962.   ShowMessage (CP[65]);
  963.   scanz ("%s", s);
  964.   c = neutral;
  965.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /* w W*/ c = white;
  966.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*b B*/ c = black;
  967.   for (p = king; p > no_piece; p--)
  968.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  969.   if(p > no_piece)
  970.   for (sq = 0; sq < 64; sq++)
  971.     {
  972.       tp = board[sq];
  973.       tc = color[sq];
  974.       board[sq] = p;
  975.       color[sq] = c;
  976.       tsq = PieceList[c][1];
  977.       PieceList[c][1] = sq;
  978.       ShowPostnValue (sq);
  979.       PieceList[c][1] = tsq;
  980.       board[sq] = tp;
  981.       color[sq] = tc;
  982.     }
  983.   score = ScorePosition (opponent);
  984.   gotoXY (TAB, 5);
  985.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  986.   ClrEoln ();
  987. #endif
  988. }
  989.  
  990. void
  991. DoTable (short table[64])
  992. {
  993. #ifdef REALLY_DEBUG
  994.   short  sq;
  995.   ExaminePosition ();
  996.   attron(BOARD_FOREGROUND);
  997.   for (sq=0;sq<64;sq++){
  998.  
  999.   gotoXY (VcoordR (sq, 2, 1));
  1000.   if (!Vblack (sq) && !flag.shade)
  1001.     OReverse ();
  1002.  
  1003.     printz ("%3d", table[sq]);
  1004.   ONormal ();
  1005.   attron(TEXT_FOREGROUND);
  1006. }
  1007. #endif
  1008. }
  1009.  
  1010.